/**
 *  This file is part of MunchLevel.
 *
 *  MunchLevel is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  MunchLevel is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with MunchLevel.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.munchlevel.view;

import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
import android.widget.TextView;

import com.munchlevel.MunchLevelApplication;
import com.munchlevel.R;
import com.munchlevel.data.PlayerInfo;

public class PlayerFightLayout extends BasePlayerLayout {

	private TextView viewPlayerName;

	public PlayerFightLayout(Context context, AttributeSet attrs) {
		this(context, attrs, 0);
	}

	public PlayerFightLayout(Context context) {
		this(context, null);
	}

	public PlayerFightLayout(Context context, AttributeSet attrs, int defStyle) {
		this(context, attrs, defStyle, null);
	}

	public PlayerFightLayout(Context context, AttributeSet attrs, int defStyle, PlayerInfo playerInfo) {
		super(context, attrs, defStyle, playerInfo);
	}

	@Override
	protected void onFinishInflate() {
		super.onFinishInflate();

		setGear(playerinfo.getGear());
		setLevel(playerinfo.getLevel());

		View playerView = findViewById(R.id.tv_playername);

		if (playerView instanceof TextView) {
			viewPlayerName = (TextView) playerView;
			MunchLevelApplication.applyFont(viewPlayerName);
		}

		// --
		super.onFinishInflate();
	}

	public void setPlayerName(String name) {
		if (TextUtils.isEmpty(name))
			name = null;

		super.setPlayerName(name);

		if (viewPlayerName != null)
			viewPlayerName.setText(name);

	}

}
